#ifndef DIAGNOSTIC2D_H
#define DIAGNOSTIC2D_H

#include "../Diagnostic/Diagnostic.h"
#include "../Input/PicParams.h"
#include "../Parallel/ParallelMPI.h"
#include "../Grid/Grid2D.h"

class PSI;

class Diagnostic2D : public Diagnostic {

public :

    Diagnostic2D(PicParams* params_, ParallelMPI* pmpi_, Grid* grid_, PhysicalField* fields_, vector<Species*>* vecSpecies_, vector<Collision*>* vecCollision_, vector<PSI*>* vecPSI_);
    virtual ~Diagnostic2D() {};

    //Runs the diag for all patches for local diags.
    virtual void run( ParallelMPI* pmpi, Grid* grid, vector<Species*>& vecSpecies, PhysicalField* fields, vector<PSI*>& vecPSI, int itime ){};

    //find the segment2d which particle cross
    bool find_cross_segment2d(Grid2D* grid2D, int iPart, int& iLine_cross, int& isegment2d_cross, bool& is_in_wall){return true;};
    
    //determine if a particle crosses a segment2d
    bool is_cross(double start_point[], double end_point[], double pos_new[], double pos_old[]){return true;};

    int n_species;
    int n_line;
    int n_segment2d_total;
    vector<int> n_segment2d;

    //particleFlux[iSpec][iLine][isegment2d]
    vector< vector< vector<double> > > particleFlux;
    vector< vector< vector<double> > > heatFlux;
    vector< vector< vector<double> > > averageAngle;
    //psiRate can be: sputteringRate, depositionRate, and so on
    vector< vector< vector<double> > > psiRate;

    vector< vector< vector<double> > > particleFlux_global;
    vector< vector< vector<double> > > heatFlux_global;
    vector< vector< vector<double> > > averageAngle_global;
    vector< vector< vector<double> > > psiRate_global;
    

    //calculate velocity and temperature of each species
    //not implemented
    void cal_VT(ParallelMPI* pmpi, vector<Species*>& vecSpecies, PhysicalField* fields, int itime){};

protected :
    double dx, dy;
    double dx_inv_, dy_inv_;
    int i_domain_begin, j_domain_begin;


};

#endif
